﻿using System.Data.Common;
using System.Threading.Tasks;

namespace DataAccess
{
    /// <summary>
    /// A database command to execute non queries
    /// </summary>
    public class NonQueryDatabaseCommand : DatabaseCommand
    {
        #region Properties

        public int AffectedRows { get; private set; }

        #endregion

        protected override int Execute(DbCommand command)
        {
            AffectedRows = command.ExecuteNonQuery();

            return AffectedRows;
        }

        protected override async Task<int> ExecuteAsync(DbCommand command)
        {
            AffectedRows = await command.ExecuteNonQueryAsync();

            return AffectedRows;
        }
    }
}
